package com.helloniu.wb.tools {

import com.helloniu.data.wb.RectStyle;
import com.helloniu.data.wb.WBColor;
import com.helloniu.wb.containers.ShapeTypeDef;

import flash.geom.Rectangle;

public class EllipseTool extends RectangularTool {
	public function EllipseTool() {
        super();
        
        this.setShapeType(ShapeTypeDef.ELLIPSE);
    }
    
    override protected function drawRectangularShape():void {
		if(getCurrWBStyle() is RectStyle) {
			setWBStyle(getCurrWBStyle());
		}

		var lineColor:WBColor = (getWBStyle() as RectStyle).lineColor;
		var lineWidth:uint = (getWBStyle() as RectStyle).lineWidth;		
		var fillColor:WBColor = (getWBStyle() as RectStyle).fillColor;
        var rect:Rectangle = calculateRect();
        
        graphics.clear();
        graphics.lineStyle(lineWidth, lineColor.color, lineColor.alpha);
        graphics.beginFill(fillColor.color, fillColor.alpha);
        graphics.moveTo(rect.x, rect.y);
        graphics.drawEllipse(rect.x, rect.y, rect.width, rect.height);
        graphics.endFill();
    }
}
}